<template>
	<view>
		<view class="good_item">
			<view class="good_left">
				<label class="radio" v-if="showRadio">
					<radio value="" :checked="good.goods_state" color="#c00000" @click="radiolist"/>
				</label>
				<image :src="good.goods_big_logo" mode=""></image>
			</view>
			<view class="good_right">
				<view class="good_text">
					<view class="name">
						{{good.goods_name}}
					</view>
				</view>
				<view class="good_pice">
				<view class="pice">
					$ {{good.goods_price | tofixet}}
				</view>
						<uni-number-box :min="1" :value="good.goods_count" v-if='showNum' @change="numderclick"></uni-number-box>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"my-goodslist",
		data() {
			return {
				
			};
		},
		props:{
			good:{
				type:Object,
				default:{}
			},
			// 控制选择框的显示与不显示
			showRadio:{
				type:Boolean,
				// 默认不显示，
				default:false
			},
			// 控制numderbox组件的显示
			showNum:{
				type:Boolean,
				default:false
			}
		},
		filters:{
			tofixet(num){
				return Number(num).toFixed(2)
			}
		},
		methods:{
			// 点击勾选返回的数据
			radiolist(){
				this.$emit('radiochange',{
					goods_id: this.good.goods_id,
					goods_state:!this.good.goods_state
				})
			},
			numderclick(val){
				console.log(val)
				this.$emit('numderChange',{
					goods_id: this.good.goods_id,
					goods_count:+val
				})
			}
		}
	}
</script>

<style lang="scss">
.good_item{
	display: flex;
	padding: 10px 5px;
	border-bottom: 1px solid #f0f0f0;
	.good_left{
		margin-right: 5px;
		display: flex;
		justify-content: space-between;
		align-items: center;
		image{
			width: 100PX;
			height: 100px;
			display: block;
		}
	}
	.good_right{
		display: flex;
		flex-direction: column;
		justify-content: space-between;
	flex: 1;
		.good_text{
			font-size: 13px;
		}
		.good_pice{
			color: #c00000;
			font-size: 16px;
			display: flex;
			justify-content: space-between;
			align-items: center;
		}
	}
}
</style>